home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group99a.txt
/
000201_icon-group-sender _Thu Sep 30 17:34:12 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id RAA28600
for icon-group-addresses; Thu, 30 Sep 1999 17:33:53 -0700 (MST)
Message-Id: <199910010033.RAA28600@baskerville.CS.Arizona.EDU>
Date: Thu, 30 Sep 1999 17:25:43 -0700
From: Steve Wampler <sbw@tapestry.tucson.az.us>
X-Accept-Language: en
To: icon-group@optima.CS.Arizona.EDU
Subject: A small puzzle
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
I haven't posted anything for a while, but thought this might be fun:
Write an Icon program to generate the pairings in a round-robin
tournament. The program should accept the player names as
command line arguments (see the example below).
In a round-robin tournament, every player plays every other player
exactly once. If there are an odd number of players, then a
special "bye" player is added.
For example, given players Alice, Bonnie, and Carole, a sample run
of the program should produce:
$ roundrobin Alice Bonnie Carole
Round 1
Court 1: Alice vs bye
Court 2: Bonnie vs Carole
Round 2
Court 1: Alice vs Bonnie
Court 2: Carole vs bye
Round 3
Court 1: Alice vs Carole
Court 2: bye vs Bonnie
Naturally, there should be no limit on the number of players. You can
assume that there are enough courts available to satisfy each round.
(As an additional challenge, implement an optional -n argument, where
n is the number of courts - this is as much an exercise in determining
a reasonable policy for handling the pairing overfow as it is an
exercise in Icon programming.)
I have a non-backtracking solution and think I know the way to do
a back-tracking one, but thought others might enjoy playing with this
problem. Send solutions to me (or back to icon-group) - I'll be
happy to look at them and summarize. Speed isn't much of
a concern - though randomly producing pairings and rejecting bad ones
probably isn't going to win great praise!
Finally, if you really have too much time on your hand, add code to
produce a scoresheet suitable for recording the results. I'd prefer
it if you provided this separately, to keep the size of the solutions
to the original problem down...
--
---
Steve Wampler {sbw@tapestry.tucson.az.us}
The gods that smiled upon your birth are laughing now. -- fortune cookie